<?php
namespace App\Models\WechatMsg;

use App\Models\RewardTimeApply;
use App\Models\RewardTimeHistory;
use App\Models\UserClock;
use App\Models\UserProject;
use App\Models\UserTeam;

class RecJoinProject
{
    public  $type;
    public $content;

    public function __construct($type, $content)
    {
        $this->content = $content;
        $this->type = $type;
    }

    public function getOrgWechatConfig()
    {
        $userProject = UserProject::where('id', $this->content['user_project_id'])->first();

        $conf['templateId'] = $userProject->user->org->wechat_message_config['apply_project_team'];

        $options = config('wechat');

        $options['app_id'] = $userProject->user->org->wechat_app_id;
        $options['secret'] = $userProject->user->org->wechat_app_secret;

        $conf['options'] = $options;

        $conf['openId'] = $userProject->project->team->user->open_id;
        $conf['url'] = env('ADMIN_URL').'/project/hire/'.$userProject->project->id;

        return $conf;
    }


    public function getMessageData()
    {
        $userProject = UserProject::where('id', $this->content['user_project_id'])->first();


        $data['first'] = '用户的报名申请';

        $data['keyword1'] =  "<{$userProject->project->name}活动>";
        $data['keyword2'] = $userProject->user->username;
        $data['keyword3'] = '项目报名申请';
        $data['keyword4'] = $userProject->created_at->format('Y-m-d H:i:s');
        $data['remark'] = '点击处理该志愿者的报名申请';

        return $data;
    }
}